package com.horay.springclouddemo.consumer.member.client;

import com.horay.springclouddemo.common.http.ResultBody;
import com.horay.springclouddemo.consumer.member.configuration.MemberConsumerConfiguration;
import com.horay.springclouddemo.model.member.Member;
import com.horay.springclouddemo.model.member.MemberDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 成员客户端
 *
 * @author heyingcheng
 * @date 2020/3/21 14:29
 */
@FeignClient(value = "demo-provider-member", configuration = MemberConsumerConfiguration.class)
@RequestMapping("member")
public interface MemberFeignClient {

    /**
     * 新增成员
     *
     * @param member
     * @author heyingcheng
     * @date 2020/3/21 14:17
     * @return boolean
     */
    @PostMapping
    ResponseEntity<ResultBody> createMember(Member member);

    /**
     * 获取成员
     *
     * @param id
     * @author heyingcheng
     * @date 2020/3/21 14:17
     * @return com.horay.springclouddemo.provider.member.model.Member
     */
    @GetMapping("{id}")
    ResponseEntity<ResultBody> getMember(@PathVariable Integer id);

    /**
     * 获取成员集合
     *
     * @param memberDTO
     * @author heyingcheng
     * @date 2020/3/21 14:18
     * @return java.util.List<com.horay.springclouddemo.provider.member.model.Member>
     */
//    @GetMapping("members")
    @RequestMapping(value = "members", method = RequestMethod.GET)
    ResponseEntity<ResultBody> getMembers(@RequestBody MemberDTO memberDTO);

    /**
     * 更新成员
     *
     * @param member
     * @author heyingcheng
     * @date 2020/3/21 14:18
     * @return boolean
     */
    @PutMapping
    ResponseEntity<ResultBody> updateMember(Member member);

    /**
     * 删除成员
     *
     * @param id
     * @author heyingcheng
     * @date 2020/3/21 14:19
     * @return boolean
     */
    @DeleteMapping("{id}")
    ResponseEntity<ResultBody> deleteMember(@PathVariable Integer id);

}
